﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-02-28
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// OP70产品入夹具
    /// </summary>
    [Verify]
    [Route("business/DcOp70Record")]
    [ApiExplorerSettings(GroupName = "business")]
    public class DcOp70RecordController : BaseController
    {
        /// <summary>
        /// OP70产品入夹具接口
        /// </summary>
        private readonly IDcOp70RecordService _DcOp70RecordService;

        public DcOp70RecordController(IDcOp70RecordService DcOp70RecordService)
        {
            _DcOp70RecordService = DcOp70RecordService;
        }

        /// <summary>
        /// 查询OP70产品入夹具列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "dcop70record:list")]
        public IActionResult QueryDcOp70Record([FromQuery] DcOp70RecordQueryDto parm)
        {
            var response = _DcOp70RecordService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询OP70产品入夹具详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "dcop70record:query")]
        public IActionResult GetDcOp70Record(long Id)
        {
            var response = _DcOp70RecordService.GetInfo(Id);

            var info = response.Adapt<DcOp70RecordDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加OP70产品入夹具
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "dcop70record:add")]
        [Log(Title = "OP70产品入夹具", BusinessType = BusinessType.INSERT)]
        public IActionResult AddDcOp70Record([FromBody] DcOp70RecordDto parm)
        {
            var modal = parm.Adapt<DcOp70Record>().ToCreate(HttpContext);

            var response = _DcOp70RecordService.AddDcOp70Record(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新OP70产品入夹具
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "dcop70record:edit")]
        [Log(Title = "OP70产品入夹具", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateDcOp70Record([FromBody] DcOp70RecordDto parm)
        {
            var modal = parm.Adapt<DcOp70Record>().ToUpdate(HttpContext);
            var response = _DcOp70RecordService.UpdateDcOp70Record(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除OP70产品入夹具
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "dcop70record:delete")]
        [Log(Title = "OP70产品入夹具", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteDcOp70Record([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_DcOp70RecordService.Delete(idArr));
        }

    }
}